package com.tadpole.music.holder.screen;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.question.UniversityBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.utils.NoDoubleClickListener;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/9/28
 */
public class ScreenCollegeViewHolder extends BaseViewHolder {
    private View itemView;
    private BaseAdapter.OnItemClickListener onItemClickListener;
    private List<UniversityBean.DataBean> collegeList;
    private TextView tvName;
    private Activity activity;
    private TextView tvDesc;
    private LinearLayout llBg;
    public ScreenCollegeViewHolder(Activity activity,View itemView, BaseAdapter.OnItemClickListener onItemClickListener,List<UniversityBean.DataBean> collegeList) {
        super(itemView);
        this.itemView = itemView;
        this.activity = activity;
        this.onItemClickListener = onItemClickListener;
        this.collegeList = collegeList;
    }

    @SuppressLint("UseCompatLoadingForDrawables")
    @Override
    public void init(final int position) {
        tvName = itemView.findViewById(R.id.tvName);
        tvDesc = itemView.findViewById(R.id.tvDesc);
        llBg = itemView.findViewById(R.id.llBg);

        tvName.setText(collegeList.get(position).getName());
        tvDesc.setText(collegeList.get(position).getChief());

        if(collegeList.get(position).isSelect()){
            llBg.setBackground(activity.getResources().getDrawable(R.drawable.shape_main_line_small));
            tvName.setTextColor(activity.getResources().getColor(R.color.colorMain));
            tvDesc.setTextColor(activity.getResources().getColor(R.color.colorMain));
        }else{
            llBg.setBackground(activity.getResources().getDrawable(R.drawable.shape_gray_line_small));
            tvName.setTextColor(activity.getResources().getColor(R.color.color_9a));
            tvDesc.setTextColor(activity.getResources().getColor(R.color.color_9a));
        }

        itemView.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onItemClickListener.onItemClick(itemView,position);
            }
        });
    }
}
